axios.defaults.baseURL='http://www.itcbc.com:8000';
toastr.options = {
    closeButton: true,//显示关闭按钮
    debug: false,
    progressBar: true,//显示进度条
    positionClass: "toast-top-center",//位置
    onclick: null,//点击消息框自定义事件
    showDuration: "300",//显示动作时间
    hideDuration: "1000",//隐藏动作时间
    timeOut: "2000",//显示时间,0为永久显示
    extendedTimeOut: "1000",//鼠标移动过后显示显示时间
    showEasing: "swing",
    hideEasing: "linear",

    showMethod: "fadeIn",//显示方式
    hideMethod: "fadeOut"//隐藏方式
 };
axios.interceptors.request.use(config => {
// Do something before request is sent
// console.log(config)
if(localStorage.getItem("liuxinKey")){
    config.headers.Authorization=localStorage.getItem('liuxinKey')
}

NProgress.start();
return config;
},error => {
// Do something with request error
return Promise.reject(error);
});
axios.interceptors.response.use(response => {
//2xx

if(response.data.code && response.data.code!==0 ){
    toastr.error(response.data.message);
}
NProgress.done();
return response;
},error => {
//4xx
if(error.response.status===401){
   window.top.location.href="./login.html"
}else if(error.response.status===400){
    NProgress.done();
}
// console.dir(error)
toastr.error(error.response.data.message)
return Promise.reject(error);
});